Skip to content

remove node types and bun types from workflows#199

Merged
ernest-nowacki merged 22 commits intomainfrom
feat/no-node-types
Mar 10, 2026
Merged

remove node types and bun types from workflows#199
ernest-nowacki merged 22 commits intomainfrom
feat/no-node-types

Conversation

@ernest-nowacki
Copy link
Contributor

@ernest-nowacki ernest-nowacki commented Feb 25, 2026

Summary

CRE workflows run inside a Javy/QuickJS WASM sandbox — not Node.js.

This is often coming back and throwing users off guard. Changes proposed in this PR aims to be solid first step to improve that experience.

Compile-time: Type-level restrictions

We're adding custom types to a whole set of common Node built-in modules (node:crypto, node:fs, node:http, node:net, etc.). This custom type mark those APIs as never which will result in clear errors when running workflows.

Our cre-sdk-examples will now present have now

We also Removed @types/node and bun-types and our cre-sdk-examples will now behave like user workflows now, correctly showing what is available.

Build-time: Static analysis validator

There's an extra step added during workflow compilation that would check for usage of restricted node modules. It would produce readable errors instead of weird WASM traces.

Screenshot 2026-03-03 at 14 48 19

What is not covered

Current implementation doesn't cover 3rd party libraries. For example if I import my-custom-hashes library which under the hoods is using unavailable NodeJS APIs we wouldn't be able to catch it as nicely as current direct node imports.

That's because it would require skipLibCheck option set to false in TypeScript which is not a common practice and we could get more reports about unrelated 3rd party libs erroring out. I will keep exploring this - but I think current proposal already uplifts DX experience of the SDK a lot.

@ernest-nowacki ernest-nowacki marked this pull request as ready for review February 26, 2026 09:32
@ernest-nowacki ernest-nowacki requested review from a team as code owners February 26, 2026 09:32
@ernest-nowacki ernest-nowacki marked this pull request as draft February 26, 2026 09:48
@ernest-nowacki ernest-nowacki marked this pull request as ready for review March 2, 2026 14:53
@ernest-nowacki ernest-nowacki marked this pull request as draft March 2, 2026 15:29
@ernest-nowacki ernest-nowacki marked this pull request as ready for review March 3, 2026 14:33
const resp = httpClient.sendRequest(nodeRuntime, req).result()
// The mathjs.org API returns the result as a raw string in the body.
// We need to parse it into a bigint.
const bodyText = new TextDecoder().decode(resp.body)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's ensure we don't break existing workflows. TextDecoder still needs to work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just "extra" cleanup in my example as using text shall be more convenient for the users. TextDecoder does in fact still work and you can still use the previous notation if you prefer.

@ernest-nowacki ernest-nowacki enabled auto-merge (squash) March 9, 2026 13:38
Copy link
Contributor

@jeffrifwaldsmartcontract jeffrifwaldsmartcontract left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach makes sense to me. Do we just continue to add libraries to the blacklist as users complain they don't work and we confirm they shouldn't work?

"noFallthroughCasesInSwitch": true,

// Do not auto-include @types/* — mirrors the customer cre cli initialized environment
"types": [],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to make sure the cre-cli tsconfigs match, or do they pull in this file directly now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will follow up with CLI PR that initialize project with this settings.

@ernest-nowacki ernest-nowacki merged commit 0a3c4fd into main Mar 10, 2026
10 checks passed
@ernest-nowacki ernest-nowacki deleted the feat/no-node-types branch March 10, 2026 01:52
@ernest-nowacki
Copy link
Contributor Author

Do we just continue to add libraries to the blacklist as users complain they don't work and we confirm they shouldn't work?

I'm aiming to do "level 2" PR which would basically go deeper into AST and do analyze libraries, similar to skipLibCheck: false option in tsconfig. We would then look for restricted imports within the SDK and show errors accordingly.

That being said I don't think we would have to do more patching of libraries. Its mostly about platform APIs that are not supported, so we go into library code, check for these, if there are no usages then library itself should be good to go.

We could only think about throwing warnings when we do Promise.all or Promise.race etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants